package com.example.perplonews.a_a_mvp.presenter.presenters

import BasePresenter
import com.blankj.utilcode.util.ToastUtils
import com.example.perplonews.a_a_mvp.contract.Login_Contract
import com.example.perplonews.a_b_entity.BaseEntity
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

class Login_Presenter(model: Login_Contract.LoginModel, view: Login_Contract.LoginView) :
    BasePresenter<Login_Contract.LoginModel, Login_Contract.LoginView>(model, view) {
    fun requestLogin(phone: Long, pwd: String, code: Int) {
        if (pwd.isEmpty()) {
            ToastUtils.showShort("当前密码为空")
            return
        }
        val map: HashMap<String, Any> = HashMap()
        map["phone"] = phone
        map["pwd"] = pwd
        map["code"] = code
        mymodel.request(map)?.subscribeOn(Schedulers.io())
            ?.observeOn(AndroidSchedulers.mainThread())
            ?.subscribe(this)
    }

    override fun onNext(t: BaseEntity) {

        myview.refreshView(t)
    }
}